class ConnectionManager:
    """维护当前所有活跃的连接"""

    def __init__(self):
        self.connections = {}

    def add_connection(self, addr, writer):
        self.connections[addr] = writer

    def remove_connection(self, addr):
        self.connections.pop(addr, None)

    def get_connection(self, addr):
        return self.connections.get(addr)

    def all_connections(self):
        return list(self.connections.keys())